﻿using System;

namespace _191_number_of_1_bits
{
    class Program
    {
        static void Main (string[] args)
        {
            
            Console.WriteLine (new Solution().HammingWeight(127));
        }
    }

    public class Solution
    {
        public int HammingWeight (uint n)
        {
            int sum = 0;
            while(n != 0)
            {
                sum++;
                n &= (n - 1);
            }
            return sum;
        }
    }
}
